home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 386 / insttest / lea_move.s < prev    next >
Text File  |  1985-11-19  |  4KB  |  108 lines

  1.  ; Program Name: LEA_MOVE.S
  2.  ;      Version: 1.003
  3.  
  4.  ; Assembly Instructions:
  5.  
  6.  ;    Assemble in Relocatabe mode and save with a TOS extension.
  7.  
  8.  ; Program Function:
  9.  
  10.  ;    Compares the relative speed and memory requirements of
  11.  
  12.  ;                      lea     label(pc), Am
  13.  ;                      move.l  An, (Am)
  14.  
  15.  ;    and               lea     label, Am
  16.  ;                      move.l  An, (Am)
  17.  
  18.  ;    to                move.l  An, label
  19.  
  20.  ; The execution time reported is for 50,000 executions of each algorithm.
  21.  
  22.  ;    In addition, this program's first AUT can disrupt the adaptive algorithm
  23.  ; because the address that is loaded in register A2 depends on the displacement
  24.  ; between the instruction "lea label(pc), a2" and the label it references.
  25.  
  26.  ;    When that instruction is executed in the adaptive algorithm, whatever
  27.  ; address is the "displacement" distance away from the instruction will be
  28.  ; loaded into register A2.  Then the instruction following, "move.l a0, (a2)
  29.  ; will write whatever is in register A0 into that memory location.
  30.  
  31.  ;    If the address stored in register A2 while the AUT is being executed by
  32.  ; the adaptive algorithm happens to be within the adaptive algorithm's program
  33.  ; or data space, the results could be unpleasant.
  34.  
  35.  ;    In fact, an undisciplined store of this type is capable of corrupting any
  36.  ; instruction or data that happens to be separated from the LEA instruction by
  37.  ; an amount equal to the displacement, and the results could be catastrophic.
  38.   
  39. calculate_program_size:
  40.  lea        -$102(pc), a1       ; Fetch basepage start address.
  41.  lea        program_end, a0     ; Fetch program end = array address.
  42.  trap       #6                  ; Return unused memory to op system.
  43.  lea        stack, a7
  44.  
  45. initialize_registers_1:
  46.  lea        header_1, a0       
  47.  lea        header_2, a1
  48.  lea        lea_move_start, a3
  49.  lea        lea_move_end, a4
  50.  lea        heading, a5
  51.  move.w     #50000, d7
  52.  trap       #9
  53.  
  54. initialize_registers_2:
  55.  lea        header_3, a0       
  56.  lea        header_4, a1
  57.  lea        long_lea_start, a3
  58.  lea        long_lea_end, a4
  59.  lea        heading, a5
  60.  move.b     #0, (a5)            ; Store a NULL in first byte to create a
  61.  move.w     #50000, d7          ; null string so that heading gets printed
  62.  trap       #9                  ; only once.
  63.  
  64. initialize_registers_3:
  65.  lea        header_5, a0       
  66.  lea        header_6, a1
  67.  lea        move_start, a3
  68.  lea        move_end, a4
  69.  lea        heading, a5
  70.  move.w     #50000, d7     
  71.  trap       #9             
  72.  
  73. terminate:
  74.  trap       #8
  75.  
  76. lea_move_start:                  ; This algorithm is potentially nocuous to
  77.  lea        label(pc), a2        ; the adaptive algorithm because a displacement 
  78.  move.l     a0, (a2)             ; will be stored in A2, not an address.
  79. lea_move_end:
  80.  
  81. long_lea_start:                  ; This algorithm poses no threat because an
  82.  lea        label, a2            ; address in this program's data area will be
  83.  move.l     a0, (a2)             ; stored in A2.
  84. long_lea_end:
  85.  
  86. move_start:                      ; This algorithm poses no threat because an
  87.  move.l     a0, label            ; address in this program's data area will be
  88. move_end:                        ; stored in A2.
  89.          
  90.  data
  91. heading:      dc.b       "LEA_MOVE Program Results",$D,$A,$D,$A,0
  92. header_1:     dc.b       "  Elapsed time for lea    label(pc), Am ",$D,$A
  93.               dc.b       "                   move.l An, (Am):      ",0
  94. header_2:     dc.b       "  Memory required for first algorithm:      ",0
  95. header_3:     dc.b $D,$A,"  Elapsed time for lea    label, Am ",$D,$A
  96.               dc.b       "                   move.l An, (Am):      ",0
  97. header_4:     dc.b       "  Memory required for second algorithm:     ",0
  98. header_5:     dc.b $D,$A,"  Elapsed time for move.l An, label:     ",0
  99. header_6:     dc.b       "  Memory required for third algorithm:      ",0
  100.  bss
  101.  align
  102. label:        ds.l  1
  103.               ds.l 96
  104. stack:        ds.l  0
  105. program_end:  ds.l  0 
  106.  end
  107.  
  108.